--三思可矣
local sansikeyi = fk.CreateSkill {
    name = "mcdh_sansikeyi"
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

sansikeyi:addEffect(fk.EventPhaseStart,{
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(self) and target.phase == Player.Finish and #lib.getPublicCards(player) == 0 and player:getMark("@@mcdh_sansikeyi-round") == 0
    end,
    on_cost =  function(self, event, target, player, data)
        local room = player.room
        local all_choices = {"#mcdh_sansikeyi-1","#mcdh_sansikeyi-2","cancle"}
        local choices = {"#mcdh_sansikeyi-1","#mcdh_sansikeyi-2","cancle"}
        if #room:canMoveCardInBoard() == 0 then
            table.removeOne(choices,"#mcdh_sansikeyi-2")
        end
        local  choice = room:askForChoice(player, choices, self.name,"#mcdh_sansikeyi", nil, all_choices)
        if choice ~= "cancle" then
            self.cost_data = choice
            return true
        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local choice = self.cost_data
        if choice == "#mcdh_sansikeyi-1" then
            local  cards = player:drawCards(2,self.name)
            for _, id in ipairs(cards) do
                local card = Fk:getCardById(id)
                room:setCardMark(card,"@@mcdh_overt_card" , 1)
            end
        else
            local targets = room:askToChooseToMoveCardInBoard(player,{prompt="#mcdh_sansikeyi-move",skill_name=self.name,cancelable=false})
            room:askToMoveCardInBoard(player,{target_one=targets[1],target_two=targets[2],skill_name =self.name,cancelable=false})
            room:setPlayerMark(player,"@@mcdh_sansikeyi-round",1)
        end
    end
})

Fk:loadTranslationTable {
    ["mcdh_sansikeyi"] = "三思可矣",
    [":mcdh_sansikeyi"] = "每名角色结束阶段，若你没有明置牌，你可以选择一项：1.摸两张牌并明置；2.移动场上一张牌，本轮本技能失效。",
    ["#mcdh_sansikeyi-1"] = "1.摸两张牌并明置",
    ["#mcdh_sansikeyi-2"] = "2.移动场上一张牌，本轮本技能失效。",
    ["#mcdh_sansikeyi"] = "三思可矣:选择一项",
    ["#mcdh_sansikeyi-move"] = "三思可矣:移动场上一张牌",
    ["@@mcdh_sansikeyi-round"] = "三思可矣失效"
}

return sansikeyi